package com.siping.java基础;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

/**
 * @author Yang Xu
 * @date 2021/9/6 15:59
 * @description:
 */
public class TreeMapTest {
    public static void main(String[] args) {
        TreeMap<Integer, Object> map = new TreeMap<>((o1, o2) -> o1 > o2 ? -1 : 1);
        map.put(3, "3");
        map.put(4, "4");
        map.put(2, "2");
        map.put(1, "1");
        map.put(9, "9");
        map.put(10, "10");
        map.put(5, "5");
        Set<Map.Entry<Integer, Object>> entries = map.entrySet();
        for (Map.Entry<Integer, Object> entry : entries) {
            System.out.println(entry.getKey());
        }
    }
}
